package me.sunpeng.springboot.springbootkafka.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author sp
 * @create 2022-04-20
 */
@RestController
@RequestMapping("/api/kafka")
public class ProducerController {

    @Autowired
    KafkaTemplate<String, String> kafka;

    @GetMapping("/msg")
    public String data(String msg) {
        //通过kafaka发送出去
        kafka.send("fisrt",msg);
        return "ok";
    }
}
